<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('用户管理')" />

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
        <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">记录时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="jlsj" id="test5" placeholder="yyyy-MM-dd HH:mm:ss" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">错误级别</label>
                            <select name="jb" lay-filter="aihao">
                                <option value=""></option>
                                <option value="0">全部</option>
                                <option value="1" selected="">调试</option>
                                <option value="2">信息</option>
                                <option value="3">警告</option>
                                <option value="4">错误</option>
                            </select>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">记录时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="test2" placeholder="yyyy-MM-dd HH:mm:ss" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">select2选择测试</label>
                        <div class="layui-input-inline">
                            <select lay-ignore="lay-ignore" class="js-data-example-ajax" name="select2cs" style="width: 193px"></select>
                        </div>
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload">搜索</a>
                    </div>
                    <div class="moreSearch" style="display: none">
                        <div class="layui-inline">
                            <label class="layui-form-label">记录时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="jlsj2" id="test1" placeholder="yyyy-MM-dd HH:mm:ss" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">错误级别</label>
                            <select name="jb2" lay-filter="aihao">
                                <option value=""></option>
                                <option value="0" selected="">全部</option>
                                <option value="1">调试</option>
                                <option value="2">信息</option>
                                <option value="3">警告</option>
                                <option value="4">错误</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">记录时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="test3" placeholder="yyyy-MM-dd HH:mm:ss" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">select2选择测试</label>
                            <div class="layui-input-inline">
                                <select lay-ignore="lay-ignore" class="js-data-example-ajax" name="select2cs" style="width: 193px"></select>
                            </div>
                        </div>
                    </div>
                </form>
            <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
            <div class="group-button" id="toolbar">
                <a class="layui-btn layui-btn-sm layui-btn-danger" id="delBtn">
                    <i class="iconfont">&#xe626;</i> 删除
                </a>
                <a class="layui-btn layui-btn-sm layui-btn-normal add-btn">
                    <i class="layui-icon">&#x1005;</i> 添加
                </a>
                <a class="layui-btn layui-btn-sm layui-btn-normal" th:href="@{/wmsreservations/downRervationsExport}">
                    <i class="layui-icon">&#x1005;</i> 下载模板
                </a>
                <a class="layui-btn layui-btn-sm layui-btn-normal" id="load">
                    <i class="layui-icon">&#x1005;</i> 导出
                </a>
                <a class="layui-btn layui-btn-sm layui-btn-normal">
                    <i class="layui-icon">&#x1005;</i> 导入
                </a>
                <!-- Single button -->
                <div class="btn-group">
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        多选操作 <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="#">多选删除</a></li>
                        <li><a href="#">多选打印</a></li>
                        <li><a href="#">明细表</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                    </ul>
                </div>
            </div>
            <!--列表-->
            <section class="panel panel-padding layui-card-body" >
                <div class="pro">
                    <table id="table"></table>
                </div>
            </section>
        </div>
    </div>
    </div>
</div>
</body>


<div th:include="public/public_js::public_js"></div>
<style type="text/css">

</style>
<script>
    $(function () {
        $(".moreBtn").on("click",function () {
            $(".moreSearch").toggle();
        });
        $("#load").on("click",function(){
            //console.log(123);
            var data = {
                ids:[],
                page:0,
                rows:10
            };
            var xhr = new XMLHttpRequest();
            xhr.open("POST", "http://localhost:9191/zxsswms/WmsDeliveryDetailsController/ShippingdetailsExcel", true);
            xhr.responseType = "blob";
            xhr.setRequestHeader('Accept', 'application/json');
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.setRequestHeader('Charset', 'utf-8');
            xhr.onload = function() {
                if (this.status == 200) {
                    var name = xhr.getResponseHeader("Content-disposition");
                    name=decodeURI(name);
                    var filename = name.substring(20,name.length);
                    var blob = new Blob([xhr.response], {type: 'text/xls'});
                    var csvUrl = URL.createObjectURL(blob);
                    var link = document.createElement('a');
                    link.href = csvUrl;
                    link.download = filename;
                    link.click();
                }
            };
            xhr.send(JSON.stringify({
                "ids": [],
                "page":0,
                "rows":10
            }));
            /*$.ajax({
                //方法类型
                type: "POST",
                //几个参数需要注意一下
                url: "http://localhost:9191/zxsswms/WmsDeliveryDetailsController/ShippingdetailsExcel" ,
                responseType: 'blob',
                data: JSON.stringify({
                        "ids": [],
                        "page":0,
                        "rows":10
                    }),

                contentType:"application/json;charset=UTF-8",
                success: function (res){
                    // var name = xhr.getResponseHeader("Content-disposition");
                    var filename = "导出列表.xls";//name.substring(20,name.length);
                    var blob = new Blob([res]);//res, {type: 'text/xls'}
                    var csvUrl = URL.createObjectURL(blob);
                    var link = document.createElement('a');
                    link.href = csvUrl;
                    link.download = filename;
                    link.click();
                        /!*const content = res;
                        const blob = new Blob([content]);
                        const fileName = '导出列表.xls';
                        console.log("res",res);
                        console.log('blob',blob);
                        if ('download' in document.createElement('a')) { // 非IE下载
                            const elink = document.createElement('a');
                            elink.download = fileName;
                            elink.style.display = 'none';
                            elink.charset = 'gb2312';
                            elink.href = URL.createObjectURL(blob);
                            document.body.appendChild(elink);
                            elink.click();
                            URL.revokeObjectURL(elink.href) ;// 释放URL 对象
                            document.body.removeChild(elink)
                        } else { // IE10+下载
                            navigator.msSaveBlob(blob, fileName)
                        }*!/
                },
                error : function() {
                    alert("异常！");
                }
            });*/
            //alert(1)
        })
    });
    layui.use(['list','layer','zzpUtils','jquery','laydate'],function () {
        var zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
        zzpUtils.select2({
            elem:".js-data-example-ajax",
            url:"/wmsgoodstype/getWmsGoodsTypeByHzId"
        })
        window.operateEvent ={
            "click .layui-btn-primary":function (e, value, row, index) {
                alert(row.mc);
            }
        }
        laydate.render({
            elem: '#test5'
            ,theme: '#20a0ff'
        })
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination:true,
            url: '/sysLog/list',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'jb',
                title: '错误级别'
            },{
                field: 'mk',
                title: '模块'
            },{
                field: 'an',
                title: '按钮'
            },{
                field: 'jlsj',
                title: '记录时间'
            },{
                field: 'xx',
                title: '信息'
            },{
                field: 'ycyy',
                title: '异常原因'
            },{
                field: 'clr',
                title: '处理人'
            },{
                field: 'clsj',
                title: '处理时间'
            },{
                field: 'cljg',
                title: '处理结果'
            },{
                field: 'clzt',
                title: '处理状态'
            },{
                field:'caozuo',
                title: '操作',
                events:operateEvent,
                formatter:operateFormatter
            }],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }

        });
        $("#delBtn").on('click',function () {
            var $rows = $table.bootstrapTable('getSelections');
            if($rows.length == 0){
                layer.msg("请选择一条进行删除");
            }else{
                var ids = $.map($rows,function (row) {
                    return row.id;
                })
                alert(ids.join(','));
            }
        })

        function operateFormatter(value, row, index) {
            return [
                '<a class="layui-btn layui-btn-primary layui-btn-xs" >查看</a>',
                '<a class="layui-btn layui-btn-xs">编辑</a>',
                '<a class="layui-btn layui-btn-danger layui-btn-xs">删除</a>'
            ].join('')
        }
        $(".inline-search-btn").on('click',function () {
            zzpUtils.refreshTable("#table");
        })
        $(".add-btn").on('click',function () {
            zzpUtils.dialog({
                title:"添加发运订单",
                type:2,
                content: "/instock/addSoOrder",
                btn:[],
            });
//            var index = top.layui.layer.open({
//                title : "添加用户",
//                type : 2,
//                content : "12312",
//                success : function(layero, index){
//
////                    var body = layui.layer.getChildFrame('body', index);
////                    if(edit){
////                        body.find(".userName").val(edit.userName);  //登录名
////                        body.find(".userEmail").val(edit.userEmail);  //邮箱
////                        body.find(".userSex input[value="+edit.userSex+"]").prop("checked","checked");  //性别
////                        body.find(".userGrade").val(edit.userGrade);  //会员等级
////                        body.find(".userStatus").val(edit.userStatus);    //用户状态
////                        body.find(".userDesc").text(edit.userDesc);    //用户简介
////                        form.render();
////                    }
////                    setTimeout(function(){
////                        layui.layer.tips('点击此处返回用户列表', '.layui-layer-setwin .layui-layer-close', {
////                            tips: 3
////                        });
////                    },500)
//                }
//            });

//            top.layui.layer.full(index);
//            //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
//            $(window).on("resize",function(){
//                top.layui.layer.full(index);
//            })
        })

    });
</script>
</html>